/**
 * 验证当前用户是否已经登录
 * 如果未登录，就跳转至登录界面
 * 登录之后，需要返回之前未登录界面
 */
function loginValid(userId){
	if(null == userId || userId == ''|| userId == 'null'){
		
		//"http://localhost:8080/timefurniture/cart"
		var prePath = window.document.location.href; 
		
	    //获取主机地址之后的目录，如： "/timefurniture/cart"
	    var pathName = window.document.location.pathname; 
	    
	    //获取主机地址
	    var pos = prePath.indexOf(pathName); //21
	    //获取带"/"的项目名，如："http://localhost:8080"
	    var localhostPath = prePath.substring(0, pos);
	    
	    //项目名，如："/timefurniture"
	    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
	    
	    //完整项目路径，如："http://localhost:8080/timefurniture"
	    var rootPath = localhostPath + projectName; 
		
		location.href = rootPath + "/user/login";
		
		return ;
	}
}
